-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: fix concat to work with more iterables (GH8645) #8668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
# like deque and custom iterables (GH8645) | ||
assert_frame_equal(pd.concat((df1, df2), ignore_index=True), expected) | ||
assert_frame_equal(pd.concat([df1, df2], ignore_index=True), expected) | ||
assert_frame_equal(pd.concat((df for df in (df1, df2)), ignore_index=True), expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add tests for abc.Iterable as well (should work)
just for confirmation (https://docs.python.org/3.3/library/collections.abc.html)
as this can often be a list-like base class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gr8
one more minor - can u add the issue number in a comment in the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick clarification: do you mean replace the (GH8645) on line 2212 with (GH8668)? Or should (GH8645) be more prominent (on its own at the top of the function?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see that - I like to see the issue right at the beginning of the test function (the actual issue number)
so when someone else looks at this it's easy to find the reason for the test
@waveform80 minor comment lmk after you add that test and its green |
Updated the test to include |
|
||
.. code-block:: python | ||
|
||
In [4]: from collections import deque |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also pull out the import and df1,df2 creation before the code block as another ipython block, then u can use it in the 2nd ipython block)
so the code is not duplicated in the display (u can look above how the prior issue does this)
Done and done (common code in "what's new" pulled out into new section above, and bug reference moved to top of the new test) |
perfect - ping on green wish all PRs were this easy to review! pick some more issues! |
ping :) |
BUG: fix concat to work with more iterables (GH8645)
see easy peasy :) thanks for the effort! |
closes #8645
Enhances
pd.concat
to work with any iterable (except specifically undesired ones like pandas objects and strings). A new test is included covering tuples, lists, generator expressions, deques, and custom sequences, and all existing tests still pass. Finally, a "what's new" entry is included (not sure this last is correct - but pull requests guidelines mentioned it)